import markdown
from html2docx import html2docx

# 读取markdown文件内容
with open('math_modeling_paper.md', 'r', encoding='utf-8') as f:
    md_content = f.read()

# 将markdown转换为HTML
html_content = markdown.markdown(md_content)

# 将HTML转换为docx并保存
with open('math_modeling_paper.docx', 'wb') as f:
    doc = html2docx(html_content, title="数学建模论文")
    f.write(doc.getvalue())

print('转换完成：math_modeling_paper.docx')